package jt.classic.app.info;

import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageDecoder;
import com.sun.image.codec.jpeg.JPEGImageEncoder;

import jt.classic.system.ISystem;
import jt.classic.system.SimpleAction;
import jt.classic.system.database.SystemDataSource;
import jt.classic.system.group.GroupMapScript;
import jt.classic.system.group.IGroup;
import jt.classic.system.purview.PurviewManager;
import jt.classic.system.role.IRole;
import jt.classic.system.user.IUser;
import jt.classic.system.user.UserManager;
import jt.classic.system.utils.AnnexTool;
import jt.classic.system.wordbook.XWordbook;
import jt.classic.system.wordbook.XWordbookMain;
import jt.classic.system.wordbook.XWordbookQuery;

import net.sf.json.JSONArray;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
import org.apache.commons.httpclient.methods.PostMethod;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import org.htmlparser.Node;
import org.htmlparser.NodeFilter;
import org.htmlparser.Parser;

import org.htmlparser.filters.TagNameFilter;

import org.htmlparser.tags.ImageTag;

import org.htmlparser.util.NodeList;

import org.limp.basework.SimpleBean;
import org.limp.basework.SimpleBeanProcessor;
import org.limp.basework.Table;
import org.limp.basework.analyzer.SimpleBeanAnalyzer4HSQ;
import org.limp.basework.analyzer.TableRegisterCenter;
import org.limp.basework.console.XSystemConfig;
import org.limp.basework.console.XSystemConsole;
import org.limp.basework.console.XSystemConsoleRunException;
import org.limp.basework.impl.CommonBean4HSQ;
import org.limp.basework.impl.SimpleBeanImpl;
import org.limp.basework.processor.SingleBeanProcessor;
import org.limp.basework.tools.BaseworkUtil;

import org.limp.mine.Controller;
import org.limp.mine.DataTrimmer;
import org.limp.mine.DateTrimmer;
import org.limp.mine.Label;
import org.limp.mine.QueryJack;
import org.limp.mine.QueryJackFactory;
import org.limp.mine.StringTool;
import org.limp.mine.annex.AnnexInfo;
import org.limp.mine.annex.AnnexItem;

import java.awt.image.BufferedImage;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.StringBufferInputStream;

import java.net.HttpURLConnection;
import java.net.URL;

import java.sql.Connection;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 内容管理控制器
 * 
 * @author mido
 *
 */
public class InfoAction extends SimpleAction {
    /**
     * 新建信息目录
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward neudirectory(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String parent = StringTool.checkString(request.getParameter("parent"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            InfoManager manager = new InfoManager(conn);

            AInfoDirectory adirec = manager.getAInfoDirectoryById(parent);

            request.setAttribute("adirec", adirec);

            forward = mapping.findForward("neudirectory");
        } catch (Exception ex) {
            forward = mapping.findForward("error");
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }

    /**
     * 保存类型定义
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward savedirectory(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            XSystemConsole console = new XSystemConsole();
            Map info = (Map) console.RUN2SAVE(request, conn);

            conn.commit();

            String id = (String) info.get("ID_ID");
            String name = (String) info.get("ID_NAME");
            String iconCls = "icon-direc";
            String pid = (String) info.get("ID_PARENT");

            if (pid.equals("0")) {
                iconCls = "icon-theme";
            }

            request.setAttribute("result",
                "{success: true, id: '" + id + "', name : '" + name +
                "', iconCls : '" + iconCls + "', pid : '" + pid + "'}");
        } catch (Exception ex) {
            ISystem.catchException(request, this, ex);
            conn.rollback();
            request.setAttribute("result", "{success: false}");
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("result");
    }

    /**
     * 编辑信息类别
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward editdirectory(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String id = StringTool.checkString(request.getParameter("id"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            InfoManager manager = new InfoManager(conn);

            AInfoDirectory adirec = manager.getAInfoDirectoryById(id);

            if (adirec == null) {
                request.setAttribute("error", "栏目已被删除");
                forward = mapping.findForward("error");
            } else {
                request.setAttribute("adirec", adirec);

                forward = mapping.findForward("editdirectory");
            }
        } catch (Exception ex) {
            forward = mapping.findForward("error");
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }

    /**
     * 查看信息类别
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward viewdirectory(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String id = StringTool.checkString(request.getParameter("id"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            InfoManager manager = new InfoManager(conn);

            AInfoDirectory adirec = manager.getAInfoDirectoryById(id);

            if (adirec == null) {
                request.setAttribute("error", "栏目已被删除");
                forward = mapping.findForward("error");
            } else {
                request.setAttribute("adirec", adirec);

                forward = mapping.findForward("viewdirectory");
            }
        } catch (Exception ex) {
            forward = mapping.findForward("error");
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }

    /**
     * 修改栏目定义
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward updatedirectory(ActionMapping mapping,
        ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
        Connection conn = null;

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            XSystemConsole console = new XSystemConsole();
            Map info = (Map) console.RUN2UPDATE(request, conn);

            conn.commit();

            String id = (String) info.get("ID_ID");
            String name = (String) info.get("ID_NAME");

            request.setAttribute("result",
                "{success: true, id: '" + id + "', name : '" + name + "'}");
        } catch (Exception ex) {
            ISystem.catchException(request, this, ex);
            conn.rollback();
            request.setAttribute("result", "{success: false}");
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("result");
    }

    /**
     * 删除栏目定义
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward deletedirectory(ActionMapping mapping,
        ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
        Connection conn = null;
        String id = StringTool.checkString(request.getParameter("idid"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            InfoManager manager = new InfoManager(conn);

            if (manager.hasChildDirectory(id) ||
                    manager.hasChildInfoDirectory(id)) {
                request.setAttribute("result", "{success: false, errCode: '0'}");
            } else {
                AInfoDirectory adirec = manager.getAInfoDirectoryById(id);

                XSystemConsole console = new XSystemConsole();
                console.RUN2DELETE(request, conn);

                conn.commit();

                request.setAttribute("result",
                    "{success: true, id: '" + adirec.iparentid() + "'}");
            }
        } catch (Exception ex) {
            ISystem.catchException(request, this, ex);
            conn.rollback();
            request.setAttribute("result", "{success: false, errCode: '-1'}");
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("result");
    }

    /**
     * 信息目录树
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward directorytree(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        String id = StringTool.checkString(request.getParameter("id"));

        if (id.equals("")) {
            id = "0";
        }

        IUser user = ISystem.getSessionUser(request);

        if (user.id().equals(UserManager.GUEST_USER_ID)) {
            request.setAttribute("result", "{}");
        } else {
            try {
                SystemDataSource ds = SystemDataSource.getInstance();
                conn = ds.getConnection();

                InfoManager manager = new InfoManager(conn);
                String script = manager.getAInfoDirectoryTree(id, user);
                request.setAttribute("result", script);
            } catch (Exception ex) {
                request.setAttribute("result", "{}");
                ISystem.catchException(request, this, ex);
            } finally {
                SystemDataSource.closeConnection(conn);
            }
        }

        return mapping.findForward("result");
    }

    /**
     * 信息目录树(管理)
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward directorytree4manager(ActionMapping mapping,
        ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
        Connection conn = null;

        String id = StringTool.checkString(request.getParameter("id"));

        if (id.equals("")) {
            id = "0";
        }

        IUser user = ISystem.getSessionUser(request);

        if (user.id().equals(UserManager.GUEST_USER_ID)) {
            request.setAttribute("result", "{}");
        } else {
            try {
                SystemDataSource ds = SystemDataSource.getInstance();
                conn = ds.getConnection();

                InfoManager manager = new InfoManager(conn);
                String script = manager.getAInfoDirectoryTree4manager(id, user);
                request.setAttribute("result", script);
            } catch (Exception ex) {
                request.setAttribute("result", "{}");
                ISystem.catchException(request, this, ex);
            } finally {
                SystemDataSource.closeConnection(conn);
            }
        }

        return mapping.findForward("result");
    }

    /**
     * 信息目录树
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward directorytree4issue(ActionMapping mapping,
        ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String id = StringTool.checkString(request.getParameter("id"));

        if (id.equals("")) {
            id = "0";
        }

        IUser user = ISystem.getSessionUser(request);

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            InfoManager manager = new InfoManager(conn);
            String script = manager.getAInfoDirectoryTree4Issue(id, false,
                    false, user);
            request.setAttribute("script", script);

            forward = mapping.findForward("directorytree4issue");
        } catch (Exception ex) {
            forward = mapping.findForward("error");
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }

    /**
     * 新建信息
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward neuinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String listtype = StringTool.checkString(request.getParameter(
                    "listtype"));
        listtype = listtype.equals("") ? "directory" : listtype;
        request.setAttribute("listtype", listtype);

        String did = StringTool.checkString(request.getParameter("did"), "");

        String dkey = StringTool.checkString(request.getParameter("dkey"), "");

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            XWordbookMain wbmain = XWordbookMain.getInstance();

            // XWordbookQuery wbquery = wbmain.getWordbookQuery("info-type");
            List list = wbmain.getWord("info-type");

            if (!"".equals(did)) {
                InfoManager manager = new InfoManager(conn);
                AInfoDirectory direc = manager.getAInfoDirectoryById(did);
                request.setAttribute("direc", direc);
            } else if (!"".equals(dkey)) {
                InfoManager manager = new InfoManager(conn);
                AInfoDirectory direc = manager.getAInfoDirectoryByKey(dkey);
                request.setAttribute("direc", direc);
            }

            request.setAttribute("list", list);

            forward = mapping.findForward("neuinfo");
        } catch (Exception ex) {
            forward = mapping.findForward("error");
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }

    /**
     * 保存信息定义
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward saveinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        IUser user = ISystem.getSessionUser(request);

        String listtype = StringTool.checkString(request.getParameter(
                    "listtype"));

        /* 进入审批流程的流程key */
        String sp = StringTool.checkString(request.getParameter("sp"));

        String uniqueid = StringTool.checkString(request.getParameter(
                    "uniqueid"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            XSystemConsole console = new XSystemConsole();
            Map info = (Map) console.RUN2SAVE(request, conn);

            String id = (String) info.get("IF_ID");
            String title = (String) info.get("IF_TITLE");

            InfoManager manager = new InfoManager(conn);

            manager.updateImageInInfo(id, uniqueid);

            conn.commit();

            request.setAttribute("result", "{success: true}");
        } catch (Exception ex) {
            request.setAttribute("result", "{success: false}");
            ISystem.catchException(request, this, ex);
            conn.rollback();
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("result");
    }

    /**
     * 信息列表
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward listinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        IUser user = ISystem.getSessionUser(request);

        CommonBean4HSQ req = new CommonBean4HSQ(request);

        Map param = req.getResource();

        String pageNO = StringTool.checkString(param.get("pageNO"));

        String qname = StringTool.checkString(param.get("qname"));
        String qtype = StringTool.checkString(param.get("qtype"));
        String qdirec = StringTool.checkString(param.get("qdirec"));
        String qdirecid = StringTool.checkString(param.get("qdirecid"));
        String qstatus = StringTool.checkString(param.get("qstatus"));
        String qdate = StringTool.checkString(param.get("qdate"));

        String listtype = StringTool.checkString(param.get("listtype"));

        if (listtype.equals("")) {
            listtype = "type&directory";
        }

        request.setAttribute("listtype", listtype);

        StringBuffer where = new StringBuffer(" WHERE IF_DEL = 0 ");

        if (listtype.equals("directory")) {
            where.append(" AND ID_ID <> 0 ");
        } else if (listtype.equals("type")) {
            where.append(" AND ID_ID = 0 ");
        }

        if (!qname.equals("")) {
            where.append(" AND IF_TITLE LIKE '%" + qname + "%' ");
        }

        if (!qtype.equals("")) {
            where.append(" AND IT_NAME = '" + qtype + "' ");
        }

        if (!qdirecid.equals("")) {
            where.append(" AND ID_ID = '" + qdirecid + "' ");
        }

        if (!qstatus.equals("")) {
            where.append(" AND IF_STATUS = " + qstatus + " ");
        }

        if (!qdate.equals("")) {
            where.append(" AND IF_DATE LIKE '%" +
                DateTrimmer.formatDateForVarchar(qdate) + "%' ");
        }

        if (!ISystem.matchrole(user, "cmsinfomanager")) {
            where.append(" AND IF_USERID = '" + user.ilogid() + "' ");
        }

        Map query = new HashMap();
        query.put("qname", qname);
        query.put("qtype", qtype);
        query.put("qdirec", qdirec);
        query.put("qdirecid", qdirecid);
        query.put("qstatus", qstatus);
        query.put("qdate", qdate);

        request.setAttribute("query", query);

        String sql1 = "SELECT COUNT(IF_ID) FROM APP_INFO " + where.toString();
        String sql2 = "SELECT * FROM APP_INFO " + where.toString() +
            " ORDER BY IF_DATE DESC";

        String url = request.getContextPath() + "/app/info.do?method=listinfo";

        if (listtype.equals("directory")) {
            url += "&listtype=directory";
        } else if (listtype.equals("type")) {
            url += "&listtype=type";
        }

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            QueryJack plus = QueryJackFactory.getInstance().createQueryJack(false);

            // 设置
            plus.setParameter(QueryJackFactory.PAGINATION_SQL1, sql1);
            plus.setParameter(QueryJackFactory.PAGINATION_SQL2, sql2);
            plus.setParameter(QueryJackFactory.DATABASE_CONNECTION, conn);
            plus.setParameter(QueryJackFactory.PAGINATION_LINKSTRING, url);
            plus.setParameter(QueryJackFactory.PAGINATION_COUNT, "20");
            plus.setParameter(QueryJackFactory.PAGINATION_PAGENO, pageNO);

            // plus.setParameter(QueryJackFactory.PAGINATION_UPDATEPAGENO, "");
            List resultList = plus.work();

            // 获得跳转控制
            Controller controller = plus.getController("form1");

            // 设置调转类型
            controller.setType("input");

            // 显示标签
            Label label = plus.getLabel();

            // 设置显示标签类型
            label.setType("href");

            Object[] result = new Object[4];
            result[0] = resultList;
            result[1] = label;
            result[2] = controller;
            result[3] = pageNO;

            request.setAttribute("result", result);

            XWordbookMain wbmain = XWordbookMain.getInstance();

            List list = wbmain.getWord("info-type");

            request.setAttribute("list", list);
        } catch (Exception ex) {
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("listinfo");
    }

    /**
     * 信息(审核)列表
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward list4shinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        IUser user = ISystem.getSessionUser(request);

        CommonBean4HSQ req = new CommonBean4HSQ(request);

        Map param = req.getResource();

        String pageNO = StringTool.checkString(param.get("pageNO"));

        String qname = StringTool.checkString(param.get("qname"));
        String qtype = StringTool.checkString(param.get("qtype"));
        String qdirec = StringTool.checkString(param.get("qdirec"));
        String qdirecid = StringTool.checkString(param.get("qdirecid"));
        String qdate = StringTool.checkString(param.get("qdate"));
        String listtype = StringTool.checkString(param.get("listtype"));

        if (listtype.equals("")) {
            listtype = "type&directory";
        }

        request.setAttribute("listtype", listtype);

        StringBuffer where = new StringBuffer(
                " WHERE IF_DEL = 0 AND IF_STATUS = 0");

        if (listtype.equals("directory")) {
            where.append(" AND ID_ID <> 0 ");
        } else if (listtype.equals("type")) {
            where.append(" AND ID_ID = 0 ");
        }

        if (!qname.equals("")) {
            where.append(" AND IF_TITLE LIKE '%" + qname + "%' ");
        }

        if (!qtype.equals("")) {
            where.append(" AND IT_NAME = '" + qtype + "' ");
        }

        if (!qdirecid.equals("")) {
            where.append(" AND ID_ID = '" + qdirecid + "' ");
        }

        if (!ISystem.matchrole(user, "cmsinfoauditor")) {
            where.append(" AND 1 = -1 ");
        }

        Map query = new HashMap();
        query.put("qname", qname);
        query.put("qtype", qtype);
        query.put("qdirec", qdirec);
        query.put("qdirecid", qdirecid);
        query.put("qdate", qdate);

        request.setAttribute("query", query);

        String sql1 = "SELECT COUNT(IF_ID) FROM APP_INFO " + where.toString();
        String sql2 = "SELECT * FROM APP_INFO " + where.toString() +
            " ORDER BY IF_DATE DESC";

        String url = request.getContextPath() +
            "/app/info.do?method=list4shinfo";

        if (listtype.equals("directory")) {
            url += "&listtype=directory";
        } else if (listtype.equals("type")) {
            url += "&listtype=type";
        }

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            QueryJack plus = QueryJackFactory.getInstance().createQueryJack(false);

            // 设置
            plus.setParameter(QueryJackFactory.PAGINATION_SQL1, sql1);
            plus.setParameter(QueryJackFactory.PAGINATION_SQL2, sql2);
            plus.setParameter(QueryJackFactory.DATABASE_CONNECTION, conn);
            plus.setParameter(QueryJackFactory.PAGINATION_LINKSTRING, url);
            plus.setParameter(QueryJackFactory.PAGINATION_COUNT, "20");
            plus.setParameter(QueryJackFactory.PAGINATION_PAGENO, pageNO);

            // plus.setParameter(QueryJackFactory.PAGINATION_UPDATEPAGENO, "");
            List resultList = plus.work();

            // 获得跳转控制
            Controller controller = plus.getController("form1");

            // 设置调转类型
            controller.setType("input");

            // 显示标签
            Label label = plus.getLabel();

            // 设置显示标签类型
            label.setType("href");

            Object[] result = new Object[4];
            result[0] = resultList;
            result[1] = label;
            result[2] = controller;
            result[3] = pageNO;

            request.setAttribute("result", result);

            XWordbookMain wbmain = XWordbookMain.getInstance();

            List list = wbmain.getWord("info-type");

            request.setAttribute("list", list);
        } catch (Exception ex) {
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("list4shinfo");
    }

    /**
     * 信息(审核通过)列表
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward list4okinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        IUser user = ISystem.getSessionUser(request);

        CommonBean4HSQ req = new CommonBean4HSQ(request);

        Map param = req.getResource();

        String pageNO = StringTool.checkString(param.get("pageNO"));

        String qname = StringTool.checkString(param.get("qname"));
        String qtype = StringTool.checkString(param.get("qtype"));
        String qdirec = StringTool.checkString(param.get("qdirec"));
        String qdirecid = StringTool.checkString(param.get("qdirecid"));
        String qdate = StringTool.checkString(param.get("qdate"));
        String listtype = StringTool.checkString(param.get("listtype"));

        if (listtype.equals("")) {
            listtype = "type&directory";
        }

        request.setAttribute("listtype", listtype);

        StringBuffer where = new StringBuffer(
                " WHERE IF_DEL = 0 AND IF_STATUS = 1");

        if (listtype.equals("directory")) {
            where.append(" AND ID_ID <> 0 ");
        } else if (listtype.equals("type")) {
            where.append(" AND ID_ID = 0 ");
        }

        if (!qname.equals("")) {
            where.append(" AND IF_TITLE LIKE '%" + qname + "%' ");
        }

        if (!qtype.equals("")) {
            where.append(" AND IT_NAME = '" + qtype + "' ");
        }

        if (!qdirecid.equals("")) {
            where.append(" AND ID_ID = '" + qdirecid + "' ");
        }

        if (!qdate.equals("")) {
            where.append(" AND IF_DATE LIKE '%" +
                DateTrimmer.formatDateForVarchar(qdate) + "%' ");
        }

        if (!ISystem.matchrole(user, "cmsinfomanager")) {
            where.append(" AND IF_USERID = '" + user.ilogid() + "' ");
        }

        Map query = new HashMap();
        query.put("qname", qname);
        query.put("qtype", qtype);
        query.put("qdirec", qdirec);
        query.put("qdirecid", qdirecid);
        query.put("qdate", qdate);

        request.setAttribute("query", query);

        String sql1 = "SELECT COUNT(IF_ID) FROM APP_INFO " + where.toString();
        String sql2 = "SELECT * FROM APP_INFO " + where.toString() +
            " ORDER BY IF_DATE DESC";

        String url = request.getContextPath() +
            "/app/info.do?method=list4okinfo";

        if (listtype.equals("directory")) {
            url += "&listtype=directory";
        } else if (listtype.equals("type")) {
            url += "&listtype=type";
        }

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            QueryJack plus = QueryJackFactory.getInstance().createQueryJack(false);

            // 设置
            plus.setParameter(QueryJackFactory.PAGINATION_SQL1, sql1);
            plus.setParameter(QueryJackFactory.PAGINATION_SQL2, sql2);
            plus.setParameter(QueryJackFactory.DATABASE_CONNECTION, conn);
            plus.setParameter(QueryJackFactory.PAGINATION_LINKSTRING, url);
            plus.setParameter(QueryJackFactory.PAGINATION_COUNT, "20");
            plus.setParameter(QueryJackFactory.PAGINATION_PAGENO, pageNO);

            // plus.setParameter(QueryJackFactory.PAGINATION_UPDATEPAGENO, "");
            List resultList = plus.work();

            // 获得跳转控制
            Controller controller = plus.getController("form1");

            // 设置调转类型
            controller.setType("input");

            // 显示标签
            Label label = plus.getLabel();

            // 设置显示标签类型
            label.setType("href");

            Object[] result = new Object[4];
            result[0] = resultList;
            result[1] = label;
            result[2] = controller;
            result[3] = pageNO;

            request.setAttribute("result", result);

            XWordbookMain wbmain = XWordbookMain.getInstance();

            List list = wbmain.getWord("info-type");

            request.setAttribute("list", list);
        } catch (Exception ex) {
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("list4okinfo");
    }

    /**
     * 信息(审核未通过)列表
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward list4nginfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        IUser user = ISystem.getSessionUser(request);

        CommonBean4HSQ req = new CommonBean4HSQ(request);

        Map param = req.getResource();

        String pageNO = StringTool.checkString(param.get("pageNO"));

        String qname = StringTool.checkString(param.get("qname"));
        String qtype = StringTool.checkString(param.get("qtype"));
        String qdirec = StringTool.checkString(param.get("qdirec"));
        String qdirecid = StringTool.checkString(param.get("qdirecid"));
        String qdate = StringTool.checkString(param.get("qdate"));
        String listtype = StringTool.checkString(param.get("listtype"));

        if (listtype.equals("")) {
            listtype = "type&directory";
        }

        request.setAttribute("listtype", listtype);

        StringBuffer where = new StringBuffer(
                " WHERE IF_DEL = 0 AND IF_STATUS = -1");

        if (listtype.equals("directory")) {
            where.append(" AND ID_ID <> 0 ");
        } else if (listtype.equals("type")) {
            where.append(" AND ID_ID = 0 ");
        }

        if (!qname.equals("")) {
            where.append(" AND IF_TITLE LIKE '%" + qname + "%' ");
        }

        if (!qtype.equals("")) {
            where.append(" AND IT_NAME = '" + qtype + "' ");
        }

        if (!qdirecid.equals("")) {
            where.append(" AND ID_ID = '" + qdirecid + "' ");
        }

        if (!qdate.equals("")) {
            where.append(" AND IF_DATE LIKE '%" +
                DateTrimmer.formatDateForVarchar(qdate) + "%' ");
        }

        if (!ISystem.matchrole(user, "cmsinfomanager")) {
            where.append(" AND IF_USERID = '" + user.ilogid() + "' ");
        }

        Map query = new HashMap();
        query.put("qname", qname);
        query.put("qtype", qtype);
        query.put("qdirec", qdirec);
        query.put("qdirecid", qdirecid);
        query.put("qdate", qdate);

        request.setAttribute("query", query);

        String sql1 = "SELECT COUNT(IF_ID) FROM APP_INFO " + where.toString();
        String sql2 = "SELECT * FROM APP_INFO " + where.toString() +
            " ORDER BY IF_DATE DESC";

        String url = request.getContextPath() +
            "/app/info.do?method=list4nginfo";

        if (listtype.equals("directory")) {
            url += "&listtype=directory";
        } else if (listtype.equals("type")) {
            url += "&listtype=type";
        }

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            QueryJack plus = QueryJackFactory.getInstance().createQueryJack(false);

            // 设置
            plus.setParameter(QueryJackFactory.PAGINATION_SQL1, sql1);
            plus.setParameter(QueryJackFactory.PAGINATION_SQL2, sql2);
            plus.setParameter(QueryJackFactory.DATABASE_CONNECTION, conn);
            plus.setParameter(QueryJackFactory.PAGINATION_LINKSTRING, url);
            plus.setParameter(QueryJackFactory.PAGINATION_COUNT, "20");
            plus.setParameter(QueryJackFactory.PAGINATION_PAGENO, pageNO);

            // plus.setParameter(QueryJackFactory.PAGINATION_UPDATEPAGENO, "");
            List resultList = plus.work();

            // 获得跳转控制
            Controller controller = plus.getController("form1");

            // 设置调转类型
            controller.setType("input");

            // 显示标签
            Label label = plus.getLabel();

            // 设置显示标签类型
            label.setType("href");

            Object[] result = new Object[4];
            result[0] = resultList;
            result[1] = label;
            result[2] = controller;
            result[3] = pageNO;

            request.setAttribute("result", result);

            XWordbookMain wbmain = XWordbookMain.getInstance();

            List list = wbmain.getWord("info-type");

            request.setAttribute("list", list);
        } catch (Exception ex) {
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("list4nginfo");
    }

    /**
     * 信息列表(for 选择)
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward listinfo4select(ActionMapping mapping,
        ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
        Connection conn = null;

        IUser user = ISystem.getSessionUser(request);

        CommonBean4HSQ req = new CommonBean4HSQ(request);

        Map param = req.getResource();

        String pageNO = StringTool.checkString(param.get("pageNO"));

        String qname = StringTool.checkString(param.get("qname"));
        String qtype = StringTool.checkString(param.get("qtype"));
        String qdirec = StringTool.checkString(param.get("qdirec"));
        String qdirecid = StringTool.checkString(param.get("qdirecid"));
        String qdate = StringTool.checkString(param.get("qdate"));
        String listtype = StringTool.checkString(param.get("listtype"));

        if (listtype.equals("")) {
            listtype = "type&directory";
        }

        request.setAttribute("listtype", listtype);

        StringBuffer where = new StringBuffer(" WHERE IF_DEL = 0 ");

        if (listtype.equals("directory")) {
            where.append(" AND ID_ID <> 0 ");
        } else if (listtype.equals("type")) {
            where.append(" AND ID_ID = 0 ");
        }

        if (!qname.equals("")) {
            where.append(" AND IF_TITLE LIKE '%" + qname + "%' ");
        }

        if (!qtype.equals("")) {
            where.append(" AND IT_NAME = '" + qtype + "' ");
        }

        if (!qdirecid.equals("")) {
            where.append(" AND ID_ID = '" + qdirecid + "' ");
        }

        if (!qdate.equals("")) {
            where.append(" AND IF_DATE LIKE '%" +
                DateTrimmer.formatDateForVarchar(qdate) + "%' ");
        }

        if (!ISystem.matchrole(user, "infomanager")) {
            where.append(" AND IF_USERID = '" + user.ilogid() + "' ");
        }

        Map query = new HashMap();
        query.put("qname", qname);
        query.put("qtype", qtype);
        query.put("qdirec", qdirec);

        request.setAttribute("query", query);

        String sql1 = "SELECT COUNT(IF_ID) FROM APP_INFO " + where.toString();
        String sql2 = "SELECT * FROM APP_INFO " + where.toString() +
            " ORDER BY IF_DATE DESC";

        String url = request.getContextPath() +
            "/app/info.do?method=listinfo4select";

        if (listtype.equals("directory")) {
            url += "&listtype=directory";
        } else if (listtype.equals("type")) {
            url += "&listtype=type";
        }

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            QueryJack plus = QueryJackFactory.getInstance().createQueryJack(false);

            // 设置
            plus.setParameter(QueryJackFactory.PAGINATION_SQL1, sql1);
            plus.setParameter(QueryJackFactory.PAGINATION_SQL2, sql2);
            plus.setParameter(QueryJackFactory.DATABASE_CONNECTION, conn);
            plus.setParameter(QueryJackFactory.PAGINATION_LINKSTRING, url);
            plus.setParameter(QueryJackFactory.PAGINATION_COUNT, "20");
            plus.setParameter(QueryJackFactory.PAGINATION_PAGENO, pageNO);

            // plus.setParameter(QueryJackFactory.PAGINATION_UPDATEPAGENO, "");
            List resultList = plus.work();

            // 获得跳转控制
            Controller controller = plus.getController("form1");

            // 设置调转类型
            controller.setType("input");

            // 显示标签
            Label label = plus.getLabel();

            // 设置显示标签类型
            label.setType("href");

            Object[] result = new Object[4];
            result[0] = resultList;
            result[1] = label;
            result[2] = controller;
            result[3] = pageNO;

            request.setAttribute("result", result);

            XWordbookMain wbmain = XWordbookMain.getInstance();

            List list = wbmain.getWord("info-type");

            request.setAttribute("list", list);
        } catch (Exception ex) {
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("listinfo4select");
    }

    /**
    * 浏览信息列表
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    * @throws Exception
    */
    public ActionForward infolistPjason(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        IUser user = ISystem.getSessionUser(request);

        CommonBean4HSQ req = new CommonBean4HSQ(request);

        Map param = req.getResource();

        String qname = StringTool.checkString(param.get("qname"));
        String qtype = StringTool.checkString(param.get("qtype"));
        String qdirec = StringTool.checkString(param.get("qdirec"));
        String qdirecid = StringTool.checkString(param.get("qdirecid"));
        String qstatus = StringTool.checkString(param.get("qstatus"));
        String qdate = StringTool.checkString(param.get("qdate"));

        StringBuffer where = new StringBuffer(" WHERE IF_DEL = 0 ");

        if (!qname.equals("")) {
            where.append(" AND IF_TITLE LIKE '%" + qname + "%' ");
        }

        if (!qtype.equals("")) {
            where.append(" AND IT_NAME = '" + qtype + "' ");
        }

        if (!qdirecid.equals("")) {
            where.append(" AND ID_ID = '" + qdirecid + "' ");
        }

        if (!qstatus.equals("")) {
            where.append(" AND IF_STATUS = " + qstatus + " ");
        }

        if (!qdate.equals("")) {
            where.append(" AND IF_DATE LIKE '%" +
                DateTrimmer.formatDateForVarchar(qdate) + "%' ");
        }

        if (!ISystem.matchrole(user, "cmsinfomanager")) {
            where.append(" AND IF_USERID = '" + user.ilogid() + "' ");
        }

        String sort = StringTool.checkString(param.get("sort"));
        String dir = StringTool.checkString(param.get("dir"));

        String pageNO = StringTool.checkString(param.get("pageNO"));

        String totalCount = StringTool.checkString(param.get("totalCount"));

        String start = StringTool.checkString(param.get("start"), "0");

        String size = StringTool.checkString(param.get("limit"), "20");

        pageNO = String.valueOf((Integer.parseInt(start) / Integer.parseInt(
                    size)) + 1);

        String sql1 = "SELECT COUNT(IF_ID) FROM APP_INFO " + where.toString();
        String sql2 =
            "SELECT IF_ID,IF_TITLE,IF_DATE,IF_USERNAME,ID_NAME FROM APP_INFO " +
            where.toString();

        if (!sort.equals("") && !dir.equals("")) {
            if (sort.equals("date")) {
                sql2 += ("ORDER BY APP_INFO.IF_DATE " + dir);
            } else if (sort.equals("title")) {
                sql2 += ("ORDER BY APP_INFO.IF_TITLE " + dir);
            }
        } else {
            sql2 += "ORDER BY IF_DATE DESC";
        }

        String url = "";

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            QueryJack plus = QueryJackFactory.getInstance().createQueryJack(false);

            // 设置
            plus.setParameter(QueryJackFactory.PAGINATION_SQL1, sql1);
            plus.setParameter(QueryJackFactory.PAGINATION_SQL2, sql2);
            plus.setParameter(QueryJackFactory.DATABASE_CONNECTION, conn);
            plus.setParameter(QueryJackFactory.PAGINATION_LINKSTRING, url);
            plus.setParameter(QueryJackFactory.PAGINATION_COUNT, size);
            plus.setParameter(QueryJackFactory.PAGINATION_PAGENO, pageNO);

            // plus.setParameter(QueryJackFactory.PAGINATION_UPDATEPAGENO, "");
            List resultList = plus.work();

            // 获得跳转控制
            Controller controller = plus.getController("form1");

            // 设置调转类型
            controller.setType("input");

            // 显示标签
            Label label = plus.getLabel();

            // 设置显示标签类型
            label.setType("href");

            Object[] result = new Object[4];
            result[0] = resultList;
            result[1] = label;
            result[2] = controller;
            result[3] = pageNO;

            List list = plus.work();

            if ((list != null) && !list.isEmpty()) {
                for (int i = 0; i < list.size(); i++) {
                    Map info = (Map) list.get(i);
                    String infoid = (String) info.get("IF_ID");
                    String infotitle = (String) info.get("IF_TITLE");
                    String infodate = DateTrimmer.getYMD_LBL((String) info.get(
                                "IF_DATE"));
                    String infouser = (String) info.get("IF_USERNAME");
                    String direcName = (String) info.get("ID_NAME");

                    InfoJsonBean bean = new InfoJsonBean();
                    bean.setIdx((String) info.get(
                            QueryJackFactory.PAGINATION_NUMBER));
                    bean.setId(infoid);
                    bean.setTitle(infotitle);
                    bean.setDate(infodate);
                    bean.setUserName(infouser);
                    bean.setDirecName(direcName);

                    list.set(i, bean);
                }
            }

            JSONArray jsonArray = JSONArray.fromObject(list);

            String jsonString = "{success: true,\"totalCount\":\"" +
                label.totaldata() + "\",\"infoList\":";
            jsonString += jsonArray.toString();
            jsonString += "}";

            request.setAttribute("result", jsonString);
        } catch (Exception ex) {
            request.setAttribute("result",
                "{success: false,\"totalCount\":\"-1\"}");
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("jsonresult");
    }

    /**
     * 专题列表
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward listtheme(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        IUser user = ISystem.getSessionUser(request);

        String flumeid = user.iallgroupflumeid(",");

        String strids = UserManager.iallgroupflumeid(flumeid);

        List roleList = user.iroles();

        String roleids = "-1";

        if ((roleList != null) && !roleList.isEmpty()) {
            for (int i = 0; i < roleList.size(); i++) {
                IRole role = (IRole) roleList.get(i);

                roleids += ("," + role.id());
            }
        }

        CommonBean4HSQ req = new CommonBean4HSQ(request);

        Map param = req.getResource();

        String pageNO = StringTool.checkString(param.get("pageNO"));

        String qname = StringTool.checkString(param.get("qname"));

        StringBuffer where = new StringBuffer(" WHERE ID_PARENT = 0 ");
        where.append(" AND ID_ID = ISYS_PURVIEW.OBJ_ID ");
        where.append(" AND ISYS_PURVIEW.OBJ_TABLE = 'APP_INFO_DIRECTORY' AND (");
        where.append(
            "(ISYS_PURVIEW.PURVIEW > -1 AND ISYS_PURVIEW.ROLE_TYPE = 'group' AND ISYS_PURVIEW.ROLE_ID IN (" +
            strids + "))");
        where.append(" OR ");
        where.append(
            "(ISYS_PURVIEW.PURVIEW > -1 AND ISYS_PURVIEW.ROLE_TYPE = 'user' AND ISYS_PURVIEW.ROLE_ID = '" +
            user.id() + "')");
        where.append(" OR ");
        where.append(
            "(ISYS_PURVIEW.PURVIEW > -1 AND ISYS_PURVIEW.ROLE_TYPE = 'role' AND ISYS_PURVIEW.ROLE_ID IN (" +
            roleids + "))");
        where.append(" OR ");
        where.append("(APP_INFO_DIRECTORY.ID_USERID = '" + user.id() + "')");
        where.append(")");

        if (!qname.equals("")) {
            where.append(" AND ID_NAME LIKE '%" + qname + "%' ");
        }

        Map query = new HashMap();
        query.put("qname", qname);

        request.setAttribute("query", query);

        String sql1 =
            "SELECT COUNT(ID_ID) FROM (SELECT ID_ID FROM APP_INFO_DIRECTORY,ISYS_PURVIEW " +
            where.toString() + " GROUP BY ID_ID) A";
        String sql2 =
            "SELECT ID_ID,MAX(PURVIEW) AS PURVIEW FROM APP_INFO_DIRECTORY,ISYS_PURVIEW " +
            where.toString() + " GROUP BY ID_ID";

        String url = request.getContextPath() +
            "/app/info.do?method=listtheme";

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            InfoManager manager = new InfoManager(conn);

            QueryJack plus = QueryJackFactory.getInstance().createQueryJack(false);

            // 设置
            plus.setParameter(QueryJackFactory.PAGINATION_SQL1, sql1);
            plus.setParameter(QueryJackFactory.PAGINATION_SQL2, sql2);
            plus.setParameter(QueryJackFactory.DATABASE_CONNECTION, conn);
            plus.setParameter(QueryJackFactory.PAGINATION_LINKSTRING, url);
            plus.setParameter(QueryJackFactory.PAGINATION_COUNT, "10");
            plus.setParameter(QueryJackFactory.PAGINATION_PAGENO, pageNO);

            // plus.setParameter(QueryJackFactory.PAGINATION_UPDATEPAGENO, "");
            List resultList = plus.work();

            for (int i = 0; i < resultList.size(); i++) {
                Map info = (Map) resultList.get(i);
                String id = (String) info.get("ID_ID");
                String purview = (String) info.get("PURVIEW");
                AInfoDirectory direc = manager.getAInfoDirectoryById(id);
                resultList.set(i,
                    new Object[] { String.valueOf(i), direc, purview });
            }

            // 获得跳转控制
            Controller controller = plus.getController("form1");

            // 设置调转类型
            controller.setType("input");

            // 显示标签
            Label label = plus.getLabel();

            // 设置显示标签类型
            label.setType("href");

            Object[] result = new Object[4];
            result[0] = resultList;
            result[1] = label;
            result[2] = controller;
            result[3] = pageNO;

            request.setAttribute("result", result);
        } catch (Exception ex) {
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("listtheme");
    }

    /**
     * 编辑信息
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward editinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String id = StringTool.checkString(request.getParameter("id"));

        String listtype = StringTool.checkString(request.getParameter(
                    "listtype"));
        request.setAttribute("listtype", listtype);

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            InfoManager manager = new InfoManager(conn);

            AInfo info = manager.getAInfoById(id);

            if (info == null) {
                request.setAttribute("error", "该信息已被删除");
                forward = mapping.findForward("error");
            } else {
                request.setAttribute("info", info);

                XWordbookMain wbmain = XWordbookMain.getInstance();

                List list = wbmain.getWord("info-type");

                request.setAttribute("list", list);

                forward = mapping.findForward("editinfo");
            }
        } catch (Exception ex) {
            forward = mapping.findForward("error");
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }

    /**
     * 修改信息定义
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward updateinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String id = StringTool.checkString(request.getParameter("ifid"));

        String listtype = StringTool.checkString(request.getParameter(
                    "listtype"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            SimpleBeanProcessor processor = new SingleBeanProcessor(conn);

            TableRegisterCenter center = TableRegisterCenter.getInstance();

            Table ainfo = center.findTable("APP_INFO");

            Table aissue = center.findTable("APP_INFO_ISSUE");

            SimpleBeanAnalyzer4HSQ analyzer = new SimpleBeanAnalyzer4HSQ(request);
            SimpleBean ainfoBean = analyzer.createSingleBean(ainfo);

            SimpleBean aissueBean = analyzer.createSingleBean(aissue);

            SimpleBean aissueBeanM = analyzer.createMultiBean(aissue,
                    "countIssue");

            processor.doDelete(aissueBean, aissue);

            processor.doUpdate(ainfoBean, ainfo);

            List list = (List) aissueBeanM.getResource().get(SimpleBean.KEY);

            if ((list != null) && !list.isEmpty()) {
                for (int i = 0; i < list.size(); i++) {
                    SimpleBean bean = (SimpleBean) list.get(i);
                    processor.doSave(bean, aissue);
                }
            }

            conn.commit();

            request.setAttribute("result", "{success: true}");
        } catch (Exception ex) {
            request.setAttribute("result", "{success: false}");
            ISystem.catchException(request, this, ex);
            conn.rollback();
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("result");
    }

    /**
     * 审核通过
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward approveinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        String ids = StringTool.checkString(request.getParameter("ids"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            BaseworkUtil util = new BaseworkUtil();

            String[] idstr = ids.split(",");

            SimpleBean sb = new SimpleBeanImpl();

            for (int i = 0; i < idstr.length; i++) {
                sb.getResource().put("ifid", idstr[i]);
                sb.getResource().put("ifstatus", "1");

                util.manualUpdate("APP_INFO", sb, conn);
            }

            conn.commit();

            request.setAttribute("result", "{success: true}");
        } catch (Exception ex) {
            request.setAttribute("result", "{success: false}");
            ISystem.catchException(request, this, ex);
            conn.rollback();
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("result");
    }

    /**
     * 审核未通过
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward rejectinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        String ids = StringTool.checkString(request.getParameter("ids"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            BaseworkUtil util = new BaseworkUtil();

            String[] idstr = ids.split(",");

            SimpleBean sb = new SimpleBeanImpl();

            for (int i = 0; i < idstr.length; i++) {
                sb.getResource().put("ifid", idstr[i]);
                sb.getResource().put("ifstatus", "-1");

                util.manualUpdate("APP_INFO", sb, conn);
            }

            conn.commit();

            request.setAttribute("result", "{success: true}");
        } catch (Exception ex) {
            request.setAttribute("result", "{success: false}");
            ISystem.catchException(request, this, ex);
            conn.rollback();
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("result");
    }

    /**
     * 删除
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward deleteinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String listtype = StringTool.checkString(request.getParameter(
                    "listtype"));
        String ids = StringTool.checkString(request.getParameter("ids"));

        String[] idstr = ids.split(",");

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            InfoManager manager = new InfoManager(conn);

            XSystemConsole console = new XSystemConsole();

            for (int i = 0; i < idstr.length; i++) {
                request.setAttribute("ifid", idstr[i]);

                console.RUN2DELETE(request, conn);

                manager.cleanResourcesInInfo(idstr[i]);

                AnnexTool tool = new AnnexTool(conn);

                tool.deleteAnnex(idstr[i], "APP_INFO");
            }

            conn.commit();

            request.setAttribute("result", "{success: true}");
        } catch (Exception ex) {
            request.setAttribute("result", "{success: false}");
            ISystem.catchException(request, this, ex);
            conn.rollback();
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("result");
    }

    /**
     * 清除内容资源
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward cleanresources(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        String uniqueid = StringTool.checkString(request.getParameter(
                    "uniqueid"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            InfoManager manager = new InfoManager(conn);

            manager.cleanResourcesInInfo(uniqueid);

            conn.commit();
        } catch (Exception ex) {
            ISystem.catchException(request, this, ex);
            conn.rollback();
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return null;
    }

    /**
     * 查看信息
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward viewinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String id = StringTool.checkString(request.getParameter("id"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            InfoManager manager = new InfoManager(conn);

            AInfo info = manager.getAInfoById(id);

            if (info == null) {
                request.setAttribute("error", "该信息已被删除");
                forward = mapping.findForward("error");
            } else {
                request.setAttribute("info", info);

                forward = mapping.findForward("viewinfo");
            }
        } catch (Exception ex) {
            forward = mapping.findForward("error");
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }

    /**
     * 预览信息
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward preview(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        CommonBean4HSQ bean = new CommonBean4HSQ(request);

        String id = StringTool.checkString(bean.getResource().get("ifid"));

        if (id.equals("")) {
            IUser user = ISystem.getSessionUser(request);

            AInfo info = InfoManager.getAInfo4Preview(bean, user);

            request.setAttribute("info", info);
        } else {
            Connection conn = null;

            try {
                SystemDataSource ds = SystemDataSource.getInstance();
                conn = ds.getConnection();

                InfoManager manager = new InfoManager();

                AInfo info = manager.getAInfoById(id);

                info = InfoManager.getAInfo4Preview(bean, info.iuser());

                request.setAttribute("info", info);
            } catch (Exception ex) {
                ISystem.catchException(request, this, ex);
            } finally {
                SystemDataSource.closeConnection(conn);
            }
        }

        return mapping.findForward("preview");
    }

    /**
     * 预览信息
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward previewinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String id = StringTool.checkString(request.getParameter("id"));

        String issue = StringTool.checkString(request.getParameter("issue"));

        if (issue.equals("")) {
            issue = "directory";
        }

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            InfoManager manager = new InfoManager(conn);

            AInfo info = manager.getAInfoById(id);

            if (info == null) {
                request.setAttribute("error", "该信息已被删除");
                forward = mapping.findForward("error");
            } else {
                // if (info.ireceipt()) {
                IUser user = ISystem.getSessionUser(request);

                manager.trace(info.id(), user, request.getRemoteAddr());

                conn.commit();

                // }
                List list = manager.getTrace(info.id());

                request.setAttribute("info", info);

                request.setAttribute("list", list);

                String url = "/info/previewinfo4type.jsp";

                if (issue.equals("directory")) {
                    url = "/info/previewinfo4directory.jsp";
                }

                forward = new ActionForward();
                forward.setPath(url);
            }
        } catch (Exception ex) {
            forward = mapping.findForward("error");
            ISystem.catchException(request, this, ex);
            conn.rollback();
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }

    /**
     * 查看图片
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward viewimg(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String id = StringTool.checkString(request.getParameter("id"));
        String type = StringTool.checkString(request.getParameter("type"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            InfoManager manager = new InfoManager(conn);

            AInfoDirectory adirec = manager.getAInfoDirectoryById(id);

            if (adirec == null) {
                request.setAttribute("error", "栏目已被删除");
                forward = mapping.findForward("error");
            } else {
                byte[] img = (byte[]) adirec.getResource().get(type);

                OutputStream output = response.getOutputStream(); // 得到输出流

                // 设定输出的类型
                response.setContentType("image/jpeg;charset=UTF-8");

                // InputStream imageIn = new StringBufferInputStream(new
                // String(img));
                InputStream imageIn = new ByteArrayInputStream(img);

                // 得到输入的编码器，将文件流进行jpg格式编码
                JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(imageIn);

                // 得到编码后的图片对象
                BufferedImage image = decoder.decodeAsBufferedImage();

                // 得到输出的编码器
                JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(output);
                encoder.encode(image); // 对图片进行输出编码
                imageIn.close(); // 关闭文件流
            }
        } catch (Exception ex) {
            forward = null;
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }

    /**
     * 栏目门户页面
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward face2directory(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String id = StringTool.checkString(request.getParameter("id"));

        IUser user = ISystem.getSessionUser(request);

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            InfoManager manager = new InfoManager(conn);

            AInfoDirectory adirec = manager.getAInfoDirectoryById(id);

            if (adirec == null) {
                request.setAttribute("error", "专题栏目已被删除");
                forward = mapping.findForward("error");
            } else {
                String temppage = (String) adirec.getResource().get("ID_TEMP");

                if (temppage.equals("")) {
                    request.setAttribute("error", "专题栏目没有定义显示模板");
                    forward = mapping.findForward("error");
                } else {
                    /* 定向到外部页面链接 */
                    if ((temppage.indexOf("http://") > -1) ||
                            (temppage.indexOf("https://") > -1)) {
                        forward = new ActionForward();
                        forward.setPath(temppage);
                        forward.setRedirect(true);
                    } else {
                        request.setAttribute("adirec", adirec);

                        /* 可读取的栏目信息列表 */
                        List _childadirec = new ArrayList();

                        /* 专题下栏目列表 */
                        List childadirec = manager.getChildDirectory(id);

                        Map direcmap = new HashMap();

                        Map childinfoindirecmap = new HashMap();

                        if ((childadirec != null) && !childadirec.isEmpty()) {
                            PurviewManager purview = new PurviewManager(conn);

                            for (int i = 0; i < childadirec.size(); i++) {
                                AInfoDirectory direc = (AInfoDirectory) childadirec.get(i);

                                if (purview.purview4read(direc.id(),
                                            "directory", user)) {
                                    _childadirec.add(direc);

                                    direcmap.put(direc.id(), direc);

                                    List childinfoindirec = manager.getIssueAInfoInDirectory(user,
                                            direc.id(), 10);
                                    childinfoindirecmap.put(direc.id(),
                                        childinfoindirec);
                                }
                            }
                        }

                        request.setAttribute("direcmap", direcmap);

                        request.setAttribute("childinfoindirecmap",
                            childinfoindirecmap);

                        List childinfo = manager.getIssueAInfoInDirectory(user,
                                adirec.ikey(), -1);

                        request.setAttribute("childinfo", childinfo);

                        request.setAttribute("childadirec", _childadirec);

                        // String url = "/info.do?method=editdirectory&id=" +
                        // id;
                        forward = new ActionForward();
                        forward.setPath(temppage);
                    }
                }

                // forward.setRedirect(true);
            }
        } catch (Exception ex) {
            forward = mapping.findForward("error");
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }

    /**
     * 主题管理树
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward themetree(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        String id = StringTool.checkString(request.getParameter("id"));
        String type = StringTool.checkString(request.getParameter("type"));

        if (id.equals("")) {
            id = "0";
        }

        if (type.equals("")) {
            type = "radio";
        }

        IUser user = ISystem.getSessionUser(request);

        if (user.id().equals(UserManager.GUEST_USER_ID)) {
            request.setAttribute("result", "{}");
        } else {
            try {
                SystemDataSource ds = SystemDataSource.getInstance();
                conn = ds.getConnection();

                InfoManager manager = new InfoManager(conn);
                String script = manager.getAInfoThemeTree(id);
                request.setAttribute("result", script);
            } catch (Exception ex) {
                request.setAttribute("result", "{}");
                ISystem.catchException(request, this, ex);
            } finally {
                SystemDataSource.closeConnection(conn);
            }
        }

        return mapping.findForward("result");
    }

    /**
     * 信息导出
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward exportinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        IUser user = ISystem.getSessionUser(request);

        StringBuffer sb = new StringBuffer(
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        sb.append("<xobject>");
        sb.append("<baseinfo>");
        sb.append("<object-type>XFILE</object-type>");
        sb.append("<object-name>欧足联官网赛前已知1-1比分 切尔西球迷怒斥巴萨晋级结果内定</object-name>");
        sb.append("<object-creatorid>" + user.id() + "</object-creatorid>");
        sb.append("<object-creatorlogid>" + user.ilogid() +
            "</object-creatorlogid>");
        sb.append("<object-creator>" + user.iname() + "</object-creator>");
        sb.append("<object-createtime>" + DateTrimmer.getYMDHMS() +
            "</object-createtime>");
        sb.append("</baseinfo>");
        sb.append("<coreinfo>");
        sb.append("<fid>40</fid>");
        sb.append("<fname>欧足联官网赛前已知1-1比分 切尔西球迷怒斥巴萨晋级结果内定</fname>");
        sb.append("<ftype>bxf</ftype>");
        sb.append(
            "<fcontent><![CDATA[欧足联官网赛前已知1-1比分 切尔西球迷怒斥巴萨晋级结果内定]]></fcontent>");
        sb.append("</coreinfo>");
        sb.append("</xobject>");

        int connectionTimeout = 5000;
        int timeout = 30000;

        try {
            PostMethod post = new PostMethod((String) XSystemConfig.config()
                                                                   .getProperty("XSYSTEM_WORKSTATION_SERVICE"));

            post.setRequestHeader("Content-type", "text/xml; charset=UTF-8");
            post.setRequestHeader("User-Agent",
                "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727");

            ByteArrayRequestEntity entity = new ByteArrayRequestEntity(sb.toString()
                                                                         .getBytes());
            post.setRequestEntity(entity);

            HttpClient httpclient = new HttpClient();

            httpclient.setConnectionTimeout(connectionTimeout);
            httpclient.setTimeout(timeout);

            int result = httpclient.executeMethod(post);
            System.out.println("Response status code: " + result);
            System.out.println("Response body: ");
            System.out.println(StringTool.checkString(
                    post.getResponseBodyAsString()));
            post.releaseConnection();
        } catch (Exception ex) {
            ISystem.catchException(ex);
        } finally {
        }

        return null;
    }

    /**
     * 幻灯片信息列表
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward slidelistinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        IUser user = ISystem.getSessionUser(request);

        CommonBean4HSQ req = new CommonBean4HSQ(request);

        Map param = req.getResource();

        String pageNO = StringTool.checkString(param.get("pageNO"));

        String qname = StringTool.checkString(param.get("qname"));

        StringBuffer where = new StringBuffer(" WHERE 1 = 1 ");

        if (!ISystem.matchrole(user, "infomanager")) {
            where.append(" AND USER_ID = '" + user.id() + "' ");
        }

        if (!qname.equals("")) {
            where.append(" AND ASNAME like '%" + qname + "%' ");
        }

        request.setAttribute("qname", qname);

        String sql1 = "SELECT COUNT(AS_ID) FROM APP_INFO_SLIDE " +
            where.toString();
        String sql2 = "SELECT * FROM APP_INFO_SLIDE " + where.toString() +
            " ORDER BY CREATETIME DESC";

        String url = request.getContextPath() +
            "/app/info.do?method=slidelistinfo";

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            QueryJack plus = QueryJackFactory.getInstance().createQueryJack(false);

            // 设置
            plus.setParameter(QueryJackFactory.PAGINATION_SQL1, sql1);
            plus.setParameter(QueryJackFactory.PAGINATION_SQL2, sql2);
            plus.setParameter(QueryJackFactory.DATABASE_CONNECTION, conn);
            plus.setParameter(QueryJackFactory.PAGINATION_LINKSTRING, url);
            plus.setParameter(QueryJackFactory.PAGINATION_COUNT, "20");
            plus.setParameter(QueryJackFactory.PAGINATION_PAGENO, pageNO);

            // plus.setParameter(QueryJackFactory.PAGINATION_UPDATEPAGENO, "");
            List resultList = plus.work();

            // 获得跳转控制
            Controller controller = plus.getController("form1");

            // 设置调转类型
            controller.setType("input");

            // 显示标签
            Label label = plus.getLabel();

            // 设置显示标签类型
            label.setType("href");

            Object[] result = new Object[4];
            result[0] = resultList;
            result[1] = label;
            result[2] = controller;
            result[3] = pageNO;

            request.setAttribute("result", result);
        } catch (Exception ex) {
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("slidelistinfo");
    }

    /**
     * 制作幻灯片新闻
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward neuslideinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        return mapping.findForward("neuslideinfo");
    }

    /**
     * 制作幻灯片新闻
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward editslideinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String id = StringTool.checkString(request.getParameter("id"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            InfoManager manager = new InfoManager(conn);
            Map info = manager.getSlideInfoById(id);

            request.setAttribute("info", info);

            forward = mapping.findForward("editslideinfo");
        } catch (Exception ex) {
            forward = mapping.findForward("error");
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }

    /**
     * 保存幻灯片新闻
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward saveslideinfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            XSystemConsole console = new XSystemConsole();
            Map info = (Map) console.RUN2SAVE(request, conn);

            conn.commit();

            request.setAttribute("result", "{success: true}");
        } catch (Exception ex) {
            request.setAttribute("result", "{success: false}");
            ISystem.catchException(request, this, ex);
            conn.rollback();
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("result");
    }

    /**
     * 修改幻灯片新闻
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward updateslideinfo(ActionMapping mapping,
        ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            XSystemConsole console = new XSystemConsole();
            Map info = (Map) console.RUN2REMIX(request, conn);

            conn.commit();

            request.setAttribute("result", "{success: true}");
        } catch (Exception ex) {
            request.setAttribute("result", "{success: false}");
            ISystem.catchException(request, this, ex);
            conn.rollback();
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("result");
    }

    /**
     * 删除幻灯片新闻项
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward delslideitem(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        String id = StringTool.checkString(request.getParameter("id"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            InfoManager manager = new InfoManager(conn);
            manager.delslideitem(id);

            request.setAttribute("result", "1");

            conn.commit();
        } catch (Exception ex) {
            request.setAttribute("result", "-1");

            ISystem.catchException(request, this, ex);
            conn.rollback();
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("result");
    }

    /**
     * 删除幻灯片新闻项
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward delslide(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;
        String[] ids = StringTool.checkString(request.getParameter("ids"))
                                 .split(",");

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            if ((ids != null) && (ids.length > 0)) {
                InfoManager manager = new InfoManager(conn);

                for (int i = 0; i < ids.length; i++) {
                    if (!ids[i].equals("")) {
                        manager.delslide(ids[i]);
                    }
                }
            }

            conn.commit();

            String url = "/info.do?method=slidelistinfo";

            forward = new ActionForward();
            forward.setPath(url);
            forward.setRedirect(true);
        } catch (Exception ex) {
            forward = mapping.findForward("error");

            ISystem.catchException(request, this, ex);
            conn.rollback();
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }

    /**
     * 子栏目排序
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward sortdirectory(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;
        ActionForward forward = null;

        String parent = StringTool.checkString(request.getParameter("id"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            InfoManager manager = new InfoManager(conn);

            List list = manager.getChildDirectory(parent);

            request.setAttribute("parent", parent);

            request.setAttribute("list", list);

            forward = mapping.findForward("sortdirectory");
        } catch (Exception ex) {
            forward = mapping.findForward("error");
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return forward;
    }

    /**
     * 保存排序设置
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward savesort(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {
        Connection conn = null;

        String id = StringTool.checkString(request.getParameter("id"));
        String idx = StringTool.checkString(request.getParameter("idx"));
        String pid = StringTool.checkString(request.getParameter("pid"));
        String tid = StringTool.checkString(request.getParameter("tid"));
        String tidx = StringTool.checkString(request.getParameter("tidx"));
        String tpid = StringTool.checkString(request.getParameter("tpid"));

        try {
            SystemDataSource ds = SystemDataSource.getInstance();
            conn = ds.getConnection();

            BaseworkUtil util = new BaseworkUtil();

            SimpleBean bean = new SimpleBeanImpl();
            bean.getResource().put("idid", id);
            bean.getResource().put("idorder", idx);

            String changeIcon = pid.equals("0") ? "icon-theme" : "icon-direc";

            /* 栏目父节点发生变化 */
            if (!pid.equals(tpid)) {
                bean.getResource().put("idparent", tid);

                if (tid.equals("0")) {
                    /* 专题图标样式 */
                    changeIcon = "icon-theme";
                } else {
                    /* 栏目图标样式 */
                    changeIcon = "icon-direc";
                }
            }

            util.manualUpdate("APP_INFO_DIRECTORY", bean, conn);

            /* 目标节点非根节点 */
            if (!tid.equals("0")) {
                bean.getResource().put("idid", tid);
                bean.getResource().put("idorder", tidx);
                bean.getResource().remove("idparent");

                util.manualUpdate("APP_INFO_DIRECTORY", bean, conn);
            }

            conn.commit();

            request.setAttribute("result",
                "{success: true, changeIcon : '" + changeIcon + "'}");
        } catch (Exception ex) {
            request.setAttribute("result", "{success: false}");
            conn.rollback();
            ISystem.catchException(request, this, ex);
        } finally {
            SystemDataSource.closeConnection(conn);
        }

        return mapping.findForward("result");
    }
}
